#!/bin/sh
function show_help() {
cat << EOF
   Usage: ${0##*/} [-e] [-l LANG]
   Calculate key for ANDROID-ID found in system clipboard
   -e          Calculate extended key
   -l LANG     Use LANG instead of the one from environment
   -a ANDROID_ID 
EOF
}

func=Contrib
lang=en_US
while getopts "el:a:" opt; do
    case "$opt" in
        e)  func=Extended
            ;;
        l)  lang=$OPTARG
            ;;
        a)
        	android=$OPTARG
        	;;
        '?')
            show_help >&2
            exit 1
            ;;
    esac
done

words=( $android )
if [ ${#words[@]} -ne 1 ]
then
  echo "ANDROID_ID does not contain one word"
  exit 1
fi


hashcodeExtended(){ (cd ~/workspace/HashCode/bin;java HashCode $1 RANDOM_SECRET_EXTENDED;) }
hashcodeContrib(){ (cd ~/workspace/HashCode/bin;java HashCode $1 RANDOM_SECRET;) }

export TEXTDOMAIN=printContribKeyEmail.sh
export TEXTDOMAINDIR=${HOME}/locale

key=`hashcode$func $android`

export LC_MESSAGES=$lang

say "$func Android-ID $android"

cat <<EOF
`gettext "Thankyou"`

`gettext "Open Link"`

https://www.myexpenses.mobi/callback.html?key=${key}#verify

`printf "$(gettext "Alternative Settings")" $key`

`gettext "Best regards"`

EOF